Solve Closest Facility

Description

NoteNote:
The Solve Closest Facility operation was added at version 10.

The solve operation is performed on a network layer resource of type closest facility.

You can provide arguments to the Solve Route operation as query parameters defined in the parameters table below.

Added at 10.5

The overrides parameter allows you to specify additional settings that can influence the behavior of the solver when finding solutions for the network analysis problems.

Added at 10.4

Pass in a complete JSON representation of a travel mode through travelMode and automatically set override values for various other parameters to quickly and consistently model cars, trucks, a type of truck, and so on.

Added at 10.3

Set travelMode and automatically set override values for various other parameters to quickly and consistently model cars, trucks, a type of truck, and so on.

Added at 10.2.1

The timeOfDayIsUTC parameter allows you to specify whether timeOfDay is in UTC or the time zone of the facilities or incidents. By using timeOfDayIsUTC, you can have all routes start or end at the same time regardless of the time zone where the facilities and incidents are located.

Added at 10.1

Request Parameters

Parameter

Details

f

Description: The response format. The default response format is html.

Values: html | json

facilities

Description: The set of facilities loaded as network locations during analysis. Facilities can be specified using a simple comma/semicolon-based syntax or as a JSON structure. If facilities are not specified, preloaded facilities from the map document are used in the analysis. If an empty JSON object is passed ('{}'), preloaded facilities are ignored.

Syntax and Examples:

Simple syntax:

You can use a simple comma/semicolon-based syntax if you need to specify only facility point geometries in the default spatial reference or WGS84.

Syntax: facilities=x1,y1; x2, y2; ...; xn, yn

Example: facilities=-122.406, 37.7831; -122.405, 37.7827

JSON structures:

Using JSON structures, you can specify two types of facilities:

  • Features—Facility geometries and attributes expressed as a feature set.
  • Layer—Facilities referencing a data layer in the map service.

Features

You can specify facility geometries as well as attributes using a more comprehensive JSON structure.

The JSON structure can include the following properties:

  • features—Optional. An array of features. Either the features or url property should be specified.
  • This option was added at 10.1.
  • url—Optional. REST Query request to a feature, map, or geoprocessing service returning a JSON feature set. Either the features or url property should be specified.
  • type—Optional. The default type is features.
  • doNotLocateOnRestrictedElements—Optional. If true, the features will only be located on streets that are traversable, not on roads that are restricted due to restriction attributes or barriers. Default is true.
  • hasZ—Optional. Indicates if the features geometry contain z-values.

Each feature in this array represents a facility and it contains the following fields:

  • geometry—Specifies the facility geometry. The structure for the geometry is the same as the structure of the standard ArcGIS REST API point geometry.
  • attributes—Key-value pairs where the key is the name of the specified field, and the value is the value for the corresponding field.

Syntax 1: Using features:

{ 
"type" : "features",
"hasZ": <true|false>,
"features"  : [
{
  "geometry" : {<geometry1>},
  "attributes" : {"<field1>" : <value11>, "<field2>" : <value12>}
},
{
  "geometry" : {<geometry2>},
  "attributes" : {"<field1>" : <value21>, "<field2>" : <value22>}
}
],
"doNotLocateOnRestrictedElements" : true | false
}

Example:

{ 
"features"  : [
{
  "geometry" : {"x" : -122.406, "y" : 37.7831},
  "attributes" : {"Name" : "Hospital 1", "Attr_Drivetime" : 15.0}
},
{
  "geometry" : {"x" : -122.405, "y" : 37.7827},
  "attributes" : {"Name" : "Hospital 2", "Attr_Drivetime" : 10.0}
}
]
}

Syntax 2: Using url: (This option was added at 10.1.)

{ 
  "type" : "features",
  "url" : "<url>",
  "doNotLocateOnRestrictedElements" : true | false
}

Example:

{ 
  "type" : "features",
  "url" : "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/3/query?where=1%3D1&returnGeometry=true&outFields=*&f=json",
  "doNotLocateOnRestrictedElements" : true
}

Layer

You can specify facilities by referencing a data layer in the map service. Attribute and spatial filters can also be applied on the layer.

The JSON structure can include the following properties:

  • type—The type should be set to layer to indicate that the user is specifying the facilities by referencing a layer.
  • layerName—The name or ID of the data layer in the map service that is being referenced.
  • where—Optional. A where clause for the query filter. Any legal SQL where clause operating on the fields in the layer is allowed.
  • geometry—Optional. The geometry to apply as the spatial filter. The structure of the geometry is the same as the structure of the json geometry objects returned by the ArcGIS REST API. The geometry type is specified using the geometryType property.
  • geometryType—Optional. The type of geometry specified by the geometry property. The geometry type can be an envelope, point, line, or polygon. The default geometry type is envelope.

    Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope

  • spatialRel—Optional. The spatial relationship to be applied on the input geometry. The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is intersects (esriSpatialRelIntersects).

    Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin

Syntax:

{ 
  "type" : "layer",
  "layerName" : "<layerName>",
  "where" : "<whereClause>",
  "geometry" : {<geometry>},
  "geometryType" : "<geometryType>",
  "spatialRel" : "<spatialRel>"
}

Example:

{ 
  "type" : "layer",
  "layerName" : "Hospitals",
  "where" : "BEDS > 100"
}

incidents

Description: The set of incidents loaded as network locations during analysis. Incidents can be specified using a simple comma/semicolon-based syntax or as a JSON structure. If incidents are not specified, preloaded incidents from the map document are used in the analysis. If an empty JSON object is passed ('{}'), preloaded incidents are ignored.

Syntax and Examples:

Simple syntax:

You can use a simple comma/semicolon-based syntax if you need to specify only incident point geometries in the default spatial reference or WGS84.

Syntax: incidents=x1,y1; x2, y2; ...; xn, yn

Example: incidents=-122.406, 37.7831; -122.405, 37.7827

JSON Structures:

Using JSON structures, you can specify two types of incidents:

  • Features—Incident geometries and attributes expressed as a feature set.
  • Layer—Incidents referencing a data layer in the map service.

Features

You can specify incident geometries as well as attributes using a more comprehensive JSON structure.

The JSON structure can include the following properties:

  • features—Optional. An array of features. Either the features or url property should be specified.
  • This option was added at 10.1.
  • url—Optional. REST Query request to a feature, map, or geoprocessing service returning a JSON feature set. Either the features or url property should be specified.
  • type—Optional. The default type is features.
  • doNotLocateOnRestrictedElements—Optional. If true, the features will only be located on streets that are traversable, not on roads that are restricted due to restriction attributes or barriers. Default is true.
  • hasZ—Optional. Indicates if the features geometry contain z-values.

Each feature in this array represents an incident and it contains the following fields:

  • geometry—Specifies the incident geometry. The structure for the geometry is the same as the structure of the standard ArcGIS REST API point geometry.
  • attributes—Key-value pairs where the key is the name of the specified field, and the value is the value for the corresponding field.

Syntax:

{ 
"type" : "features",
"hasZ": <true|false>,
"features"  : [
{
  "geometry" : {<geometry1>},
  "attributes" : {"<field1>" : <value11>, "<field2>" : <value12>}
},
{
  "geometry" : {<geometry2>},
  "attributes" : {"<field1>" : <value21>, "<field2>" : <value22>}
}
],
"doNotLocateOnRestrictedElements" : true | false

}

Example:

{ 
"features"  : [
{
  "geometry" : {"x" : -122.406, "y" : 37.7831},
  "attributes" : {"Name" : "Accident 1", "Cutoff_Drivetime" : 15.0}
},
{
  "geometry" : {"x" : -122.405, "y" : 37.7827},
  "attributes" : {"Name" : "Accident 2", "Cutoff_Drivetime" : 12.0}
}
]
}

Syntax 2: Using url: (This option was added at 10.1.)

{ 
  "type" : "features",
  "url" : "<url>",
  "doNotLocateOnRestrictedElements" : true | false
}

Example:

{ 
  "type" : "features",
  "url" : "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/4/query?where=1%3D1&returnGeometry=true&outFields=&f=json",
  "doNotLocateOnRestrictedElements" : true
}

Layer

You can specify an incident by referencing a data layer in the map service. Attribute and spatial filters can also be applied on the layer.

The JSON structure can include the following properties:

  • type—The type should be set to layer to indicate that the user is specifying the incidents by referencing a layer.
  • layerName—The name or ID of the data layer in the map service that is being referenced.
  • where—Optional. A where clause for the query filter. Any legal SQL where clause operating on the fields in the layer is allowed.
  • geometry—Optional. The geometry to apply as the spatial filter. The structure of the geometry is the same as the structure of the json geometry objects returned by the ArcGIS REST API. The geometry type is specified using the geometryType property.
  • geometryType—Optional. The type of geometry specified by the geometry property. The geometry type can be an envelope, point, line, or polygon. The default geometry type is envelope.

    Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope

  • spatialRel—Optional. The spatial relationship to be applied on the input geometry. The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is intersects (esriSpatialRelIntersects).

    Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin

Syntax:

{ 
  "type" : "layer",
  "layerName" : "<layerName>",
  "where" : "<whereClause>",
  "geometry" : {<geometry>},
  "geometryType" : "<geometryType>",
  "spatialRel" : "<spatialRel>"
}

Example:

{ 
  "type" : "layer",
  "layerName" : "TrafficAccidents",
  "where" : "SEVERITY > 0"
}

barriers

Description: The set of barriers loaded as network locations during analysis. Barriers can be specified using a simple comma/semicolon-based syntax or as a JSON structure. If barriers are not specified, preloaded barriers from the map document are used in the analysis. If an empty JSON object is passed ('{}'), preloaded barriers are ignored.

Syntax and Examples:

Simple syntax:

You can use a simple comma/semicolon-based syntax if you need to specify only barrier point geometries in the default spatial reference or WGS84.

Syntax: barriers=x1,y1; x2, y2; ...; xn, yn

Example: barriers=-122.406, 37.7831; -122.405, 37.7827

JSON Structures:

Using JSON structures, you can specify two types of barriers:

  • Features—Barrier geometries and attributes expressed as a feature set.
  • Layer—Barriers referencing a data layer in the map service.

Features

You can specify barrier geometries as well as attributes using a more comprehensive JSON structure.

The JSON structure can include the following properties:

  • features—Optional. An array of features. Either the features or url property should be specified.
  • url—Optional. REST Query request to a feature, map, or geoprocessing service returning a JSON feature set. Either the features or url property should be specified.
  • type—Optional. The default type is features.
  • hasZ—Optional. Indicates if the features geometry contain z-values.

Each feature in this array represents a barrier and it contains the following fields:

  • geometry—specifies the barrier geometry. The structure for the geometry is the same as the structure of the standard ArcGIS REST API point geometry.
  • attributes—Key-value pairs where the key is the name of the specified field, and the value is the value for the corresponding field.

Syntax:

{ 
"type" : "features",
"hasZ": <true|false>,
"features"  : [
{
  "geometry" : {<geometry1>},
  "attributes" : {"<field1>" : <value11>, "<field2>" : <value12>}
},
{
  "geometry" : {<geometry2>},
  "attributes" : {"<field1>" : <value21>, "<field2>" : <value22>}
}
]
}

Example:

{ 
"features"  : [
{
  "geometry" : {"x" : -122.406, "y" : 37.7831},
  "attributes" : {"Name" : "Barrier 1"}
},
{
  "geometry" : {"x" : -122.405, "y" : 37.7827},
  "attributes" : {"Name" : "Barrier 2"}
}
]
}

Syntax 2: Using url: (This option was added at 10.1.)

{ 
  "type" : "features",
  "url" : "<url>"
}

Example:

{ 
  "type" : "features",
  "url" : "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/0/query?where=1%3D1&returnGeometry=true&f=json"
}

Layer

You can specify barriers by referencing a data layer in the map service. Attribute and spatial filters can also be applied on the layer.

The JSON structure can include the following properties:

  • type—The type should be set to layer to indicate that the user is specifying the barriers by referencing a layer.
  • layerName—The name or ID of the data layer in the map service that is being referenced.
  • where—Optional. A where clause for the query filter. Any legal SQL where clause operating on the fields in the layer is allowed.
  • geometry—Optional. The geometry to apply as the spatial filter. The structure of the geometry is the same as the structure of the json geometry objects returned by the ArcGIS REST API. The geometry type is specified using the geometryType property.
  • geometryType—Optional. The type of geometry specified by the geometry property. The geometry type can be an envelope, point, line, or polygon. The default geometry type is envelope.

    Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope

  • spatialRel—Optional. The spatial relationship to be applied on the input geometry. The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is intersects (esriSpatialRelIntersects).

    Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin

Syntax:

{ 
  "type" : "layer",
  "layerName" : "<layerName>",
  "where" : "<whereClause>",
  "geometry" : {<geometry>},
  "geometryType" : "<geometryType>",
  "spatialRel" : "<spatialRel>"
}

Example:

{ 
  "type" : "layer",
  "layerName" : "TrafficAccidents",
  "where" : "SEVERITY > 0"
}

polylineBarriers

Description: The set of polyline barriers loaded as network locations during analysis. If polyline barriers are not specified, preloaded barriers from the map document are used in the analysis. If an empty JSON object is passed ('{}') preloaded polyline barriers are ignored.

Syntax and Examples:

JSON Structures:

Using JSON structures, you can specify two types of barriers:

  • Features—Polyline barrier geometries and attributes expressed as a feature set.
  • Layer—Polyline barriers referencing a data layer in the map service.

Features

You can specify polyline barrier geometries as well as attributes using a more comprehensive JSON structure.

The JSON structure can include the following properties:

  • features—Optional. An array of features. Either the features or url property should be specified.
  • url—Optional. REST Query request to a feature, map, or geoprocessing service returning a JSON feature set. Either the features or url property should be specified.
  • type—Optional. The default type is features.
  • hasZ—Optional. Indicates if the features geometry contain z-values.

Each feature in this array represents a barrier and it contains the following fields:

  • geometry—Specifies the barrier geometry. The structure for the geometry is the same as the structure of the standard ArcGIS REST API polyline geometry.
  • attributes—Key-value pairs where the key is the name of the specified field, and the value is the value for the corresponding field.

Syntax:

{ 
"type" : "features",
"hasZ": <true|false>,
"features"  : [
{
  "geometry" : {<polyline1>},
  "attributes" : {"<field1>" : <value11>, "<field2>" : <value12>}
},
{
  "geometry" : {<polyline2>},
  "attributes" : {"<field1>" : <value21>, "<field2>" : <value22>}
}
]
}

Example:

{ 
"features"  : [
{
  "geometry" : {
    "paths" : [ 
     [ [-97.06138,32.837], [-97.06133,32.836], [-97.06124,32.834], [-97.06127,32.832] ], 
     [ [-97.06326,32.759], [-97.06298,32.755] ]
    ],
    "spatialReference" : {"wkid" : 4326}
     },
  "attributes" : {"Name" : "Barrier 1"}
},
{
  "geometry" : {
       "paths" : [ 
     [ [-97.06138,32.837], [-97.06133,32.836], [-97.06124,32.834], [-97.06127,32.832] ], 
     [ [-97.06326,32.759], [-97.06298,32.755] ]
    ],
    "spatialReference" : {"wkid" : 4326}
     },
  "attributes" : {"Name" : "Barrier 2"}
}
]
}

Syntax 2: Using url: (This option was added at 10.1.)

{ 
  "type" : "features",
  "url" : "<url>"
}


Example: 
{
  "type" : "features",
  "url" : "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/6/query?where=1%3D1&returnGeometry=true&f=json"
}

Layer

You can specify polyline barriers by referencing a data layer in the map service. Attribute and spatial filters can also be applied on the layer.

The JSON structure can include the following properties:

  • type—The type should be set to layer to indicate that the user is specifying the polyline barriers by referencing a layer.
  • layerName—The name of the data layer in the map service that is being referenced.
  • where—Optional. A where clause for the query filter. Any legal SQL where clause operating on the fields in the layer is allowed.
  • geometry—Optional. The geometry to apply as the spatial filter. The structure of the geometry is the same as the structure of the json geometry objects returned by the ArcGIS REST API. The geometry type is specified using the geometryType property.
  • geometryType—Optional. The type of geometry specified by the geometry property. The geometry type can be an envelope, point, line, or polygon. The default geometry type is envelope.

    Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope

  • spatialRel—Optional. The spatial relationship to be applied on the input geometry. The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is intersects (esriSpatialRelIntersects).

    Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin

Syntax:

{ 
  "type" : "layer",
  "layerName" : "<layerName>",
  "where" : "<whereClause>",
  "geometry" : {<geometry>},
  "geometryType" : "<geometryType>",
  "spatialRel" : "<spatialRel>"
}

Example:

{ 
  "type" : "layer",
  "layerName" : "PolylineBarrier"
}

polygonBarriers

Description: The set of polygon barriers loaded as network locations during analysis. If polygon barriers are not specified, preloaded polygon barriers from the map document are used in the analysis. If an empty JSON object is passed ('{}'), preloaded polygon barriers are ignored.

Syntax and Examples:

JSON structures:

Using JSON structures, you can specify two types of barriers:

  • Features—Polygon barrier geometries and attributes expressed as a feature set.
  • Layer—Polygon barriers referencing a data layer in the map service.

Features

You can specify polygon barrier geometries as well as attributes using a more comprehensive JSON structure.

The JSON structure can include the following properties:

  • features—Optional. An array of features. Either the features or url property should be specified.
  • url—Optional. REST Query request to a feature, map, or geoprocessing service returning a JSON feature set. Either the features or url property should be specified.
  • type—Optional. The default type is features.
  • hasZ—Optional. Indicates if the features geometry contain z-values.

Each feature in this array represents a barrier and it contains the following fields:

  • geometry—Specifies the barrier geometry. The structure for the geometry is the same as the structure of the standard ArcGIS REST API polygon geometry.
  • attributes—Key-value pairs where the key is the name of the specified field, and the value is the value for the corresponding field.

Syntax:

{ 
"type" : "features",
"features"  : [
{
  "geometry" : {<polygon1>},
  "attributes" : {"<field1>" : <value11>, "<field2>" : <value12>}
},
{
  "geometry" : {<polygon3>},
  "attributes" : {"<field1>" : <value21>, "<field2>" : <value22>}
}
]
}

Example:

{ 
"features"  : [
{
  "geometry" : {
    "rings" : [ 
     [ [-97.06138,32.837], [-97.06133,32.836], [-97.06124,32.834], [-97.06127,32.832], [-97.06138,32.837] ], 
     [ [-97.06326,32.759], [-97.06298,32.755], [-97.06153,32.749], [-97.06326,32.759] ]
    ],
    "spatialReference" : {"wkid" : 4326}
    },
  "attributes" : {"Name" : "Barrier 1"}
},
{
  "geometry" : {
     "rings" : [ 
     [ [-97.06138,32.837], [-97.06133,32.836], [-97.06124,32.834], [-97.06127,32.832], [-97.06138,32.837] ], 
     [ [-97.06326,32.759], [-97.06298,32.755], [-97.06153,32.749], [-97.06326,32.759] ]
    ],
    "spatialReference" : {"wkid" : 4326}
   },
  "attributes" : {"Name" : "Barrier 2"}
}
]
}

Syntax 2: Using url: (This option was added at 10.1.)

{ 
  "type" : "features",
  "url" : "<url>"
}

Example:

{ 
  "type" : "features",
  "url" : "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/7/query?where=1%3D1&returnGeometry=true&f=json"
}

Layer

You can specify polygon barriers by referencing a data layer in the map service. Attribute and spatial filters can also be applied on the layer.

The JSON structure can include the following properties:

  • type—The type should be set to layer to indicate that the user is specifying the polygon barriers by referencing a layer.
  • layerName—The name or ID of the data layer in the map service that is being referenced.
  • where—Optional. A where clause for the query filter. Any legal SQL where clause operating on the fields in the layer is allowed.
  • geometry—Optional. The geometry to apply as the spatial filter. The structure of the geometry is the same as the structure of the json geometry objects returned by the ArcGIS REST API. The geometry type is specified using the geometryType property.
  • geometryType—Optional. The type of geometry specified by the geometry property. The geometry type can be an envelope, point, line, or polygon. The default geometry type is envelope.

    Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope

  • spatialRel—Optional. The spatial relationship to be applied on the input geometry. The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is intersects (esriSpatialRelIntersects).

    Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin

Syntax:

{ 
  "type" : "layer",
  "layerName" : "<layerName>",
  "where" : "<whereClause>",
  "geometry" : {<geometry>},
  "geometryType" : "<geometryType>",
  "spatialRel" : "<spatialRel>"
}

Example:

{ 
  "type" : "layer",
  "layerName" : "PolygonBarrier"
}

travelMode

Added at 10.4

Travel modes provide override values that help you quickly and consistently model a vehicle or mode of transportation. By setting a travel mode, you don't need to explicitly set values for the following parameters:

  • impedanceAttributeName
  • attributeParameterValues
  • restrictUTurns
  • useHierarchy
  • restrictionAttributeNames
  • outputGeometryPrecision
  • outputGeometryPrecisionUnits

CautionCaution:

When setting travelMode, the service overrides the values of the parameters listed above with those defined in the travel mode, even if you specify their values explicitly in the request.

Example:

To use an existing travel mode that was preconfigured in the service, the typical workflow would be as follows:

  1. Find what travel modes have been preconfigured for the service by making a call to the retrieveTravelMode operation on the service. For example, http://<my server>:6080/arcgis/rest/services/<service name>/NAServer/ClosestFacility/retrieveTravelModes?f=pjson

  2. In the JSON that is returned, look up the supportedTravelModes name, whose value is an array containing the various travel modes.

    Example supportedTravelModes value.

    {
     "defaultTravelMode": "1",
     "supportedTravelModes": [
      {
       "name": "Driving Time",
       "id": "1",
       "type": "AUTOMOBILE",
       "description": "Finds the best route in a car minimizing time.",
       "timeAttributeName": "TravelTime",
       "distanceAttributeName": "Meters",
       "impedanceAttributeName": "TravelTime",
       "restrictionAttributeNames": [
        "Oneway",
        "Driving an Automobile"
       ],
       "attributeParameterValues": [
        {
         "attributeName": "Oneway",
         "parameterName": "Restriction Usage",
         "value": "Prohibited"
        },
        {
         "attributeName": "Driving an Automobile",
         "parameterName": "Restriction Usage",
         "value": "Prohibited"
        },
        {
         "attributeName": "Driving a Truck",
         "parameterName": "Restriction Usage",
         "value": "Prohibited"
        }
       ],
       "useHierarchy": true,
       "uturnAtJunctions": "esriNFSBAtDeadEndsAndIntersections",
       "simplificationTolerance": 10,
       "simplificationToleranceUnits": "esriMeters"
      },
      {
       "name": "Trucking Distance",
       "id": "2",
       "type": "TRUCK",
       "description": "Finds the best route in a truck minimizing distance.",
       "timeAttributeName": "Minutes",
       "distanceAttributeName": "Meters",
       "impedanceAttributeName": "Meters",
       "restrictionAttributeNames": [
        "Driving a Truck",
        "Oneway"
       ],
       "attributeParameterValues": [
        {
         "attributeName": "Oneway",
         "parameterName": "Restriction Usage",
         "value": "Prohibited"
        },
        {
         "attributeName": "Driving an Automobile",
         "parameterName": "Restriction Usage",
         "value": "Prohibited"
        },
        {
         "attributeName": "Driving a Truck",
         "parameterName": "Restriction Usage",
         "value": "Prohibited"
        }
       ],
       "useHierarchy": true,
       "uturnAtJunctions": "esriNFSBNoBacktrack",
       "simplificationTolerance": 10,
       "simplificationToleranceUnits": "esriMeters"
      }
     ] 
    }
    

  3. The defaultTravelMode tag has the ID of the travel mode that was configured to be used by default. So, in the above example, you would get the travel mode with "id" : "1" if you wanted the default travel mode.
  4. Pass the JSON for the travel mode as the travelMode parameter value. In the case where you wanted to pass in the default travel mode, you would pass in the following:

    Example: travelMode parameter value.

    {
       "name": "Driving Time",
       "id": "1",
       "type": "AUTOMOBILE",
       "description": "Finds the best route in a car minimizing time.",
       "timeAttributeName": "TravelTime",
       "distanceAttributeName": "Meters",
       "impedanceAttributeName": "TravelTime",
       "restrictionAttributeNames": [
        "Oneway",
        "Driving an Automobile"
       ],
       "attributeParameterValues": [
        {
         "attributeName": "Oneway",
         "parameterName": "Restriction Usage",
         "value": "Prohibited"
        },
        {
         "attributeName": "Driving an Automobile",
         "parameterName": "Restriction Usage",
         "value": "Prohibited"
        },
        {
         "attributeName": "Driving a Truck",
         "parameterName": "Restriction Usage",
         "value": "Prohibited"
        }
       ],
       "useHierarchy": true,
       "uturnAtJunctions": "esriNFSBAtDeadEndsAndIntersections",
       "simplificationTolerance": 10,
       "simplificationToleranceUnits": "esriMeters"
      }
    

    NoteNote:

    It is not required to pass in the same exact information as an existing travel mode. You can start from an existing travel mode and just change some of the settings prior to passing it in. Or, you can create your own travel mode JSON with whatever values you want as long as it conforms to the correct schema.

attributeParameterValues

Description:

A set of attribute parameter values that can be parameterized to determine which network elements can be used by a vehicle.

The parameter holding a vehicle characteristic is compared to a value coming from a descriptor attribute to determine whether or not a network element is traversable. For example, a parameterized restriction attribute can compare the height of your vehicle with a descriptor attribute that holds the clearance under overpasses through tunnels. If the vehicles height is greater than the clearance, the edge is restricted.

Parameterized cost attributes that can reference other cost attributes and scale them can also be used. This is useful when inclement weather, such as ice, fog or heavy rain, descends on the study area and hinders normal flow of traffic. By having a parameter already outfitted on a cost attribute, travel-time expectations and traversable network paths can be adjusted with respect to changes in traffic speeds.

Syntax:

[ 
{
  "attributeName" : "<attribute1>",
  "parameterName" : "<parameter1>",
  "value" : "<value1>"
}, 
{
  "attributeName" : "<attribute2>",
  "parameterName" : "<parameter2>",
  "value" : "<value2>"
}
]

Example:

[
{ 
  "attributeName" : "Time",
  "parameterName" : "65 MPH",
  "value" : "5.0"
}
]

returnDirections

Description: If true, directions will be generated and returned with the analysis results. Default is true.

The directions are available in the directions property of the JSON response.

Values: true | false

directionsLanguage

Description: The language to be used when computing directions. The default is as defined in the network layer. The list of supported languages can be found in the REST layer description.

Example: directionsLanguage=en

directionsOutputType

Description: Defines content, verbosity of returned directions. The default is esriDOTStandard.

Values: esriDOTComplete | esriDOTCompleteNoEvents | esriDOTFeatureSets | esriDOTInstructionsOnly | esriDOTStandard | esriDOTSummaryOnly

directionsStyleName

Description: The style to be used when returning the directions. The default is as defined in the network layer. The list of supported styles can be found in the REST layer description.

Example: directionsStyleName=NA Navigation

directionsLengthUnits

Description: The length units to use when computing directions. The default is as defined in the network layer.

Values: esriNAUFeet | esriNAUKilometers | esriNAUMeters | esriNAUMiles | esriNAUNauticalMiles | esriNAUYards | esriNAUUnknown

directionsTimeAttributeName

Description: The name of network attribute to use for the drive time when computing directions. The default is as defined in the network layer.

Example: directionsTimeAttributeName=DriveTime

returnCFRoutes

Description: If true, closest facilities routes will be returned with the analysis results. Default is true.

The routes are available in the routes property of the JSON response.

Values: true | false

returnFacilities

Description: If true, facilities will be returned with the analysis results. Default is false.

The facilities are available in the facilities property of the JSON response.

Values: true | false

returnIncidents

Description: If true, incidents will be returned with the analysis results. Default is false.

The incidents are available in the incidents property of the JSON response.

Values: true | false

returnBarriers

Description: If true, barriers will be returned with the analysis results. Default is false.

The barriers are available in the barriers property of the JSON response.

Values: true | false

returnPolylineBarriers

Description: If true, polyline barriers will be returned with the analysis results. Default is false.

The polyline barriers are available in the polylineBarriers property of the JSON response.

Values: true | false

returnPolygonBarriers

Description: If true, polygon barriers will be returned with the analysis results. Default is false.

The polygon barriers are available in the polygonBarriers property of the JSON response.

Values: true | false

outputLines

Description: The type of output lines to be generated in the result. The default is as defined in the network layer.

Values: esriNAOutputLineNone | esriNAOutputLineStraight | esriNAOutputLineTrueShape | esriNAOutputLineTrueShapeWithMeasure

defaultCutoff

Description: The default cutoff value to stop traversing.

Values: <double>

defaultTargetFacilityCount

Description: The default number of facilities to find.

Values: <integer>

travelDirection

Description: Options for traveling to or from the facility. The default is defined in the network layer.

Values: esriNATravelDirectionFromFacility | esriNATravelDirectionToFacility

outSR

Description: The well-known ID of the spatial reference for the geometries returned with the analysis results. If outSR is not specified, the geometries are returned in the spatial reference of the map.

accumulateAttributeNames

Description: The list of network attribute names to be accumulated with the analysis. The default is as defined in the network layer.

The value should be specified as a comma separated list of attribute names.

You can also specify a value of none to indicate that no network attributes should be accumulated.

Example: accumulateAttributeNames=WalkingMinutes,Meters

impedanceAttributeName

Description: The network attribute name to be used as the impedance attribute in analysis. The default is as defined in the network layer.

Example: impedanceAttributeName=DrivingMinutes

restrictionAttributeNames

Description: The list of network attribute names to be used as restrictions with the analysis. The default is as defined in the network layer.

The value should be specified as a comma separated list of attribute names.

You can also specify a value of none to indicate that no network attributes should be used as restrictions.

Example: restrictionAttributeNames=Oneway

restrictUTurns

Description: Specifies how U-Turns should be restricted in the analysis. The default is as defined in the network layer.

Values: esriNFSBAllowBacktrack | esriNFSBAtDeadEndsOnly | esriNFSBNoBacktrack | esriNFSBAtDeadEndsAndIntersections

useHierarchy

Description: If true, the hierarchy attribute for the network should be used in analysis. The default is as defined in the network layer.

Values: true | false

outputGeometryPrecision

Description: The precision of the output geometry after generalization. If 0, no generalization of output geometry is performed. The default is as defined in the network service configuration. If present and positive, it represents the MaximumAllowableOffset parameter—generalization is performed according to IPolycurve.Generalize.

Example: outputGeometryPrecision=0.5

outputGeometryPrecisionUnits

Description: The units of the output geometry precision. The default value is esriUnknownUnits.

Values: esriUnknownUnits | esriCentimeters | esriDecimalDegrees | esriDecimeters | esriFeet | esriInches | esriKilometers | esriMeters | esriMiles | esriMillimeters | esriNauticalMiles | esriPoints | esriYards

timeOfDay

Description: Arrival or departure date and time. For example, if travelDirection is set to esriNATravelDirectionToFacility and timeOfDayUsage is set to esriNATimeOfDayUseAsEndTime and timeOfDay is set to 8:00 AM, the route(s) built will arrive at the Facility at 8:00 in the morning local time. This example assumes timeOfDayIsUTC is set to the default value of false. If the value is true, the facility is reached at 8:00 a.m. UTC.

Values: Specified by number of milliseconds since midnight Jan 1st, 1970, UTC.

timeOfDayIsUTC

This option was added at 10.2.1.

Description: The time zone of the timeOfDay parameter.

By setting this parameter to false, which is the default value, the timeOfDay parameter refers to the time zone in which the facilities or incidents are located.

  • If timeOfDayUsage is set to esriNATimeOfDayUseAsStartTime and travelDirection is esriNATravelDirectionFromFacility, this is the time zone of the facilities.
  • If timeOfDayUsage is set to esriNATimeOfDayUseAsStartTime and travelDirection is esriNATravelDirectionToFacility, this is the time zone of the facilities.
  • If timeOfDayUsage is set to esriNATimeOfDayUseAsEndTime and travelDirection is esriNATravelDirectionFromFacility, this is the time zone of the facilities.
  • If timeOfDayUsage is set to End_Time and travelDirection is esriNATravelDirectionToFacility, this is the time zone of the facilities.

By setting timeOfDayIsUTC to true, the timeOfDay parameter refers to Coordinated Universal Time (UTC). Choose this option if you want to find what's nearest for a specific time, such as now, but aren't certain in which time zone the facilities or incidents will be located.

Values: true | false

timeOfDayUsage

Description: Defines the way the timeOfDay value is used. The default is as defined in the network layer.

Values: esriNATimeOfDayUseAsStartTime | esriNATimeOfDayUseAsEndTime

returnZ

This option was added at 10.1.

Description: If true, z-values will be included in the returned routes and compressed geometry if the network dataset is z-aware. The default is false.

overrides

Specify additional settings that can influence the behavior of the solver when finding solutions for the network analysis problems.

The value for this parameter needs to be specified in JavaScript Object Notation (JSON). The values can be a number, Boolean, or string.

{
"overrideSetting1" : "value1", 
"overrideSetting2" : "value2"
}

The default value for this parameter is no value, which indicates not to override any solver settings.

Overrides are advanced settings that should be used only after careful analysis of the results obtained before and after applying the settings. A list of supported override settings for each solver and their acceptable values can be obtained by contacting EsriTechnical Support.

Example Usage

Example 1: http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Closest Facility/solveClosestFacility?incidents={"features":[{"geometry" : {"x" : -122.396, "y" : 37.6831},"attributes" : {"Name" : "Accident 1"}}]}&facilities={"features":[{"geometry" : {"x" : -122.406, "y" : 37.7831},"attributes" : {"Name" : "Hospital 1"}},{"geometry" : {"x" : -122.405, "y" : 37.7827},"attributes":{"Name" : "Hospital 2"}}]}&barriers=&polylineBarriers=&polygonBarriers=&travelDirection=esriNATravelDirectionToFacility&defaultCutoff=15&defaultTargetFacilityCount=1&outSR=4326&accumulateAttributeNames=&impedanceAttributeName=Time&restrictionAttributeNames=OneWay,TurnRestriction,Avoid passenger ferries,Non-routeable segments&attributeParameterValues=&restrictUTurns=esriNFSBAllowBacktrack&useHierarchy=true&returnDirections=true&returnCFRoutes=true&returnFacilities=false&returnIncidents=false&returnBarriers=false&returnPolylineBarriers=false&returnPolygonBarriers=false&directionsLanguage=&directionsStyleName=NA Desktop&outputLines=esriNAOutputLineTrueShape&outputGeometryPrecision=&outputGeometryPrecisionUnits=esriUnknownUnits&directionsTimeAttributeName=Time&directionsLengthUnits=esriNAUMiles&f=pjson

JSON Response Syntax

{
  "routes"            : { 
                          "spatialReference" : { <spatialReference> },
						  "hasZ": <true|false>,
						  "hasM": <true|false>,
                          "features" : [ <array of <polyline> features> ] 
                        },
  "facilities"        : { 
                          "spatialReference" : { <spatialReference> },
						  "hasZ": <true|false>,
                          "features" : [ <array of <point> features> ] 
                        },
  "incidents"         : {
                          "spatialReference" : { <spatialReference> },
						  "hasZ": <true|false>,
                          "features" : [ <array of <point> features> ] 
                        },
  "barriers"          : { 
                          "spatialReference" : { <spatialReference> },
						  "hasZ": <true|false>,
                          "features" : [ <array of <point> features> ] 
                        },
  "polylineBarriers"  : {
                          "spatialReference" : { <spatialReference> },
						  "hasZ": <true|false>,
                          "features" : [ <array of <polyline> features> ] 
                        },
  "polygonBarriers"   : {
                          "spatialReference" : { <spatialReference> },
                          "features" : [ <array of <polygon> features> ] 
                        },
  "directions"        : [ {<route1>}, {<route2>},... ],
  "messages"          : [ {<message1>}, {<message2>},... ]
}

where each features object is defined as:

  "features": [
  {
    "attributes": {
      "<field1>": <value11>,
      "<field2>": <value12>
    },
    "geometry": {<geometry1>}
  },
  {
    "attributes": {
      "<field1>": <value21>,
      "<field2>": <value22>
    },
    "geometry": {<geometry2>}
  }
  ]

each route object in the directions property are defined as:
  
{
  "routeId": <routeId>,
  "routeName": "<routeName>",
  "summary": {
    "totalLength": <totalLength>,
    "totalTime": <totalTime>,
    "totalDriveTime": <totalDriveTime>,
    "envelope": {<envelope>}
  },
  "hasZ": <true|false>,
  "features": [
    {
      "attributes" : 
      {
        "length": <length1>,
        "time": <time1>,
        "text": "<text1>",
        "ETA": <ETA>,
        "maneuverType": "<maneuverType1>"
      },
      "compressedGeometry": "<compressedGeometry1>"
    },
    {
      "attributes" : 
      {
        "length": <length2>,
        "time": <time2>,
        "text": "<text2>",
        "maneuverType": "<maneuverType2>"
      },
      "compressedGeometry": "<compressedGeometry2>"
    }
  ]
}

and each message is defined as:

{ "type" : <type1>, "description" : <description1> }

JSON Response Example

{
  "routes" : {"spatialReference" : {
      "wkid" : 4326
    }, 
    
    "features" : [
      {
        "attributes" : {
          "ObjectID" : 1, 
          "FacilityID" : 2, 
          "FacilityRank" : 1, 
          "Name" : "Accident 1 - Hospital 2", 
          "IncidentCurbApproach" : 1, 
          "FacilityCurbApproach" : 1, 
          "IncidentID" : 1, 
          "Total_Time" : 10.681003218051, 
          "Shape_Length" : 0.123693665336013
        }
        , 
        "geometry" : 
        {
          "paths" : 
          [
            [
              [-122.395844761, 37.6832247680001], 
              [-122.395337, 37.6825930000001], 
              [-122.395127, 37.6822990000001], 
              [-122.395078, 37.6822100000001], 
              [-122.394961, 37.6820240000001], 
              [-122.394864, 37.681839], 
              [-122.394719, 37.681497], 
              [-122.39465, 37.681275], 
              [-122.394578, 37.681046], 
              [-122.3945, 37.681068], 
              [-122.39443, 37.6810760000001], 
              [-122.394464, 37.6812190000001], 
              [-122.40428, 37.780963], 
              [-122.404422, 37.781073], 
              [-122.404422001, 37.781073001], 
              [-122.404946, 37.7814910000001], 
              [-122.405487, 37.78193], 
              [-122.405962, 37.7823090000001], 
              [-122.405179949, 37.7829275240001]
            ]
          ]
        }
      }
    ]
  }, 
  "directions" : [
    {
      "routeId" : 1, 
      "routeName" : "Accident 1 - Hospital 2", 
      "summary" : {
        "totalLength" : 8.08519598918001, 
        "totalTime" : 10.6666666666667, 
        "totalDriveTime" : 10.681003218051, 
        "envelope" : {
          "xmin" : -122.408392, 
          "ymin" : 37.681046, 
          "xmax" : -122.39443, 
          "ymax" : 37.7829275239333, 
          "spatialReference" : {
            "wkid" : 4326
          }
        }
      }, 
      "features" : [
        {
          "attributes" : {
            "length" : 0, 
            "time" : 0, 
            "text" : "Start at Accident 1", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTDepart"
          }, 
          "compressedGeometry" : "+1m91-6fjtc+1vtgu+0+0"
        }, 
        {
          "attributes" : {
            "length" : 0.150853254241241, 
            "time" : 0.259400404989719, 
            "text" : "Go southeast on Bayshore Blvd", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTStraight"
          }, 
          "compressedGeometry" : "+1m91-6fjtc+1vtgu+18-1j+e-q+c-v"
        }, 
        {
          "attributes" : {
            "length" : 2.1656530667998, 
            "time" : 3.72155529726297, 
            "text" : "Make U-turn and go back on Bayshore Blvd", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTUTurn"
          }, 
          "compressedGeometry" : "+1m91-6fjra+1vtdi+4-d+9+2-b+v-g+t-h+p-t+15-10+14-10+v-1k+1c-4q+3l-29+1q-10+11-12+1b-f+o-n+18-1a+2j-6b+ct-8+o-3+l+0+14+3+u+9+l+1m+35+10+23+a+r+1v+4e"
        }, 
        {
          "attributes" : {
            "length" : 0.598385652527213, 
            "time" : 1.02499999850988, 
            "text" : "Continue on Bay Shore Blvd", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTStraight"
          }, 
          "compressedGeometry" : "+1m91-6fkdq+1vusg+h+t+f+15+c+n+1b+1n+l+10+8+9+b+b+g+a+e+6+1u+h+o+e+12+11+1i+1l+g+p+7+h"
        }, 
        {
          "attributes" : {
            "length" : 0.115576051175594, 
            "time" : 0.196666669100523, 
            "text" : "At fork keep left on Bay Shore Blvd", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTForkLeft"
          }, 
          "compressedGeometry" : "+1m91-6fk2s+1vv83+b+12+8+h+5+e+3+c+0+d"
        }, 
        {
          "attributes" : {
            "length" : 3.56891432413399, 
            "time" : 3.38341818004847, 
            "text" : "Take ramp on the left and go on US Hwy 101 N toward Civic Center/Bay Bridge", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTRampLeft"
          }, 
          "compressedGeometry" : "+1m91-6fk21+1vvat-p+2b-9+13-l+18-g+1n-k+1q-20+51-h+1j-2b+63-9+i-1d+2c-2a+4c-3f+5q-f+t-8+n-9+u-7+12-3+18+3+18+8+18+7+n+9+o+l+17+k+r+23+2i+j+t+d+s+b+u+32+9o+6+k+4+r+3+13-1+10-d+4e-5+q-6+l-f+q-k+o-j+g-1j+16-g+d-f+h-d+h-7+d-7+i-4+h-1+f+1+g+7+t+g+10+10+1j+8+l+7+j+4+n+3+n+2+1k"
        }, 
        {
          "attributes" : {
            "length" : 0.557037940125038, 
            "time" : 0.514848945662379, 
            "text" : "Go toward Seventh St", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTStraight"
          }, 
          "compressedGeometry" : "+1m91-6fkd1+201vc+1+p-1+p-l+6h-4+e-8+l-17+1q-b+l-6+g-5+j+0+s"
        }, 
        {
          "attributes" : {
            "length" : 0.139812714384474, 
            "time" : 0.193322874605656, 
            "text" : "Take ramp on the right to 7th St toward US Hwy 101", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTRampRight"
          }, 
          "compressedGeometry" : "+1m91-6fkfv+202d0+4+b+j+v+8+8+n+h+6+8+2+5+1+b-1+4-3+4"
        }, 
        {
          "attributes" : {
            "length" : 0.184959217304317, 
            "time" : 0.312160110566765, 
            "text" : "Continue on 7th St", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTStraight"
          }, 
          "compressedGeometry" : "+1m91-6fke4+202g3-44+39"
        }, 
        {
          "attributes" : {
            "length" : 0.344728539097515, 
            "time" : 0.589068286120892, 
            "text" : "Turn right on Folsom St", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTTurnRight"
          }, 
          "compressedGeometry" : "+1m91-6fki8+202jc+7o+64"
        }, 
        {
          "attributes" : {
            "length" : 0.198729099388571, 
            "time" : 0.340110473334789, 
            "text" : "Turn left on 5th St", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTTurnLeft"
          }, 
          "compressedGeometry" : "+1m91-6fkag+202pg-4e+3i"
        }, 
        {
          "attributes" : {
            "length" : 0.0605461300022504, 
            "time" : 0.145451977849007, 
            "text" : "Turn right on Minna St", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTTurnRight"
          }, 
          "compressedGeometry" : "+1m91-6fkeu+202t2+1b+12"
        }, 
        {
          "attributes" : {
            "length" : 0, 
            "time" : 0, 
            "text" : "Finish at Hospital 2", 
            "ETA" : -2209161600000, 
            "maneuverType" : "esriDMTStop"
          }, 
          "compressedGeometry" : "+1m91-6fkdj+202u4+0+0"
        }
      ]
    }
  ], 
  "messages" : [
  ]
}